package com.learn.security.controller;

import com.learn.security.bo.ApiResult;
import com.learn.security.bo.LoginInfo;
import com.learn.security.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author : Yu.Tan
 * @date : 2023/6/27 17:02
 * @desc : **
 */
@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    /**
     * 登录方法
     * <p>
     * loginAccount：user
     * password：123456
     *
     * @param loginInfo
     * @return
     */
    @PostMapping("/login")
    public ApiResult login(@Valid @RequestBody LoginInfo loginInfo) {
        return authService.login(loginInfo.getLoginAccount(), loginInfo.getPassword());
    }

}
